<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <style>
        .main {
            width: 300px;
            margin: auto;
        }

        .box1 {
            /* 把元素变为弹性盒子的容器 */
            display: flex;
            width: 100px;
            border: 1px solid #000;
            /* 设置主轴对齐方式：两侧对齐 */
            justify-content: space-between;
            /* 设置交叉轴对齐：居中 */
            align-items: center;
        }

        .box2 {
            /* 把元素变为弹性盒子的容器 */
            display: flex;
            border: 1px solid #000;
            width: 40px;
            height: 100px;
            /* 改变主轴方向：改为垂直方向 */
            flex-direction: column;
            /* 设置主轴对齐方式：两侧对齐 */
            justify-content: space-between;
            /* 设置交叉轴对齐：居中 */
            align-items: center;
        }
        .div1 {
            width: 20px;
            height: 20px;
            border-radius: 50%;
            background-color: #f00;
        }

        .div2 {
            width: 40px;
            height: 40px;
            border-radius: 50%;
            background-color: #ff0;
        }

        .div3 {
            width: 20px;
            height: 20px;
            border-radius: 50%;
            background-color: #0f0;
        }
    </style>
</head>

<body>
    <main class="main">
        <h2>弹性盒子案例</h2>
        <p>把三个盒子，以左中右的方式排列</p>
        <div class="box1">
            <div class="div1"></div>
            <div class="div2"></div>
            <div class="div3"></div>
        </div>
        <p>把三个盒子，以上中下的方式排列</p>
        <div class="box2">
            <div class="div1"></div>
            <div class="div2"></div>
            <div class="div3"></div>
        </div>
    </main>
</body>

</html>